package org.finesys.boot.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.finesys.common.core.module.R;
import org.finesys.system.api.dto.ClientDetailsDto;
import org.finesys.system.api.entity.SysOauthClientDetails;
import org.finesys.system.api.service.ClientService;
import org.finesys.system.convert.SysOauthClientDetailsConvert;
import org.finesys.system.service.SysOauthClientDetailsService;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;

@Service
@RequiredArgsConstructor
public class ClientServiceImpl implements ClientService {
    private final SysOauthClientDetailsService sysOauthClientDetailsService;

    public R<ClientDetailsDto> getByClientId(@PathVariable("clientId") String clientId) {
        SysOauthClientDetails sysOauthClientDetails = sysOauthClientDetailsService.getOne(Wrappers.<SysOauthClientDetails>lambdaQuery().eq(SysOauthClientDetails::getClientId, clientId), false);
        return R.success(SysOauthClientDetailsConvert.INSTANCE.convert(sysOauthClientDetails));
    }
}
